﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LAVAA.BL.Business;
using LAVAA.DAL;

namespace LAVAA.BL.Control
{
    public class UserGroupFacade
    {
        UnitOfWork _uow = new UnitOfWork();

        public void AddUserGroup(UserGroup group)
        {
            UserGroupManager userGroupMgr = new UserGroupManager(_uow);
            userGroupMgr.AddUserGroup(group);
            _uow.Commit();
        }

        public void DeleteUserGroup(Guid groupId)
        {
            UserGroupManager userGroupMgr = new UserGroupManager(_uow);
            userGroupMgr.DeleteUserGroup(groupId);
            _uow.Commit();
        }

        public void UpdateUserGroup(UserGroup userGroup)
        {
            UserGroupManager userGroupMgr = new UserGroupManager(_uow);
            userGroupMgr.UpdateUserGroup(userGroup);
            _uow.Commit();
        }

        public UserGroup FindUserGroupById(Guid id)
        {
            return _uow.UserGroupRepository.Find(filter: a => a.Id == id).FirstOrDefault();
        }

        public IEnumerable<UserGroup> GetAllUserGroups()
        {
            return _uow.UserGroupRepository.GetAll();
        }
    }
}
